package com.zrf.base.knowledge.proxy.dynamicProxy;

import com.zrf.base.knowledge.proxy.Interface;
import com.zrf.base.knowledge.proxy.InterfaceImpl;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * 动态代理main
 *
 * @author zhouruifeng
 *         create at 2017/3/5.
 */
public class DynamicMain {
    public static void main(String[] args) {
        Interface i = new InterfaceImpl();

        InvocationHandler invocationHandler = new DynamicProxy(i);
        Interface proxyInstance = (Interface) Proxy.newProxyInstance(Interface.class.getClassLoader(), new Class[]{Interface.class}, invocationHandler);
        proxyInstance.doSomeThing();

    }
}
